package com.tongqin.distributed.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.PropertySource;

import javax.sql.DataSource;

/**
 * @author yuantongqin
 * @date 2018/8/23 下午5:51
 */
@Configurable
@ComponentScan(basePackages = "com.tongqin.distributed")
@PropertySource(value ="classpath:db.properties" )
public class DataSourceConfig {

    @Bean(name = "dataSource")
    public DataSource dataSource(){
        DruidDataSource dataSource = new DruidDataSource();
        //类型连接池
        dataSource.setDbType("POOLED");

        dataSource.setDriverClassName("");
        dataSource.setUrl("");
        dataSource.setUsername("");
        dataSource.setPassword("");

        return dataSource;
    }

}
